package com.igeekhome.ccs.controller;

import com.igeekhome.ccs.biz.ICustomerAndJobBiz;
import com.igeekhome.ccs.biz.IJobBiz;
import com.igeekhome.ccs.entity.Customer;
import com.igeekhome.ccs.entity.CustomerAndJob;
import com.igeekhome.ccs.entity.Job;
import com.igeekhome.ccs.mapper.JobMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//工单详情页面
@Controller
@RequestMapping("/jobDetail")
public class JobDetailController {
    @Autowired
    JobMapper jobMapper;
    @Autowired
    ICustomerAndJobBiz iCustomerAndJobbiz;
    @Autowired
    IJobBiz iJobBiz;

    /**
     *显示工单信息和客户信息
     */
    @RequestMapping("/selectDetail")
    public @ResponseBody
    CustomerAndJob selectDetail(int jobId){
        CustomerAndJob caj=new CustomerAndJob();
        Job jb=new Job();
        jb.setJobId(jobId);
        Customer cs=new Customer();
        cs.setCustomerId(jobMapper.getcsid(jobId));
        caj.setCs(cs);
        caj.setJb(jb);
        CustomerAndJob ok=iCustomerAndJobbiz.selectDetail(caj);
        System.out.println(ok);
        return ok;
    }

    /**
     *更改工单状态
     */
    @RequestMapping("/updatastatus")
    public @ResponseBody
    int updatastates(int jobId,String status,String content){
        iJobBiz.updatastates(jobId,status,content);
        return 0;
    }

    /**
     * 转交工单
     */
    @RequestMapping("deliverjob")
    public @ResponseBody
    int deliverjob(int jobId,int customerId,String content){
        iJobBiz.deliverjob(jobId,customerId,content);
        return 0;
    }
    /**
     * 编辑工单
     */
    @RequestMapping("resetjob")
    public @ResponseBody
    int resetjob(Job jb){



        return 0;
    }
}
